import { createRouter, createWebHistory } from 'vue-router'
import { routerMap } from './routes'
import useStore from '@/store'

const router = createRouter({
    history: createWebHistory(),
    routes: routerMap
})

router.beforeEach((to, from, next) => {
    const { nav } = useStore()
    const name: any = to.name
    nav.setCurrentName(name)
    next()
})

export default router